package com.crm.crm.mapper;

import com.crm.entity.Partner;
import com.crm.model.Workers;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface CrmSelectMapper {

    @Results(id = "partnerMap",
            value = {
                    @Result(column = "org_type", property = "orgType", typeHandler = com.crm.typehandler.JsonTypeHandler.class),
                    @Result(column = "telephone_list", property = "telephoneList", typeHandler = com.crm.typehandler.JsonTypeHandler.class),
                    @Result(column = "over_area", property = "overArea", typeHandler = com.crm.typehandler.JsonTypeHandler.class),
                    @Result(column = "asset_info", property = "assetInfo", typeHandler = com.crm.typehandler.JsonTypeHandler.class),
                    @Result(column = "fund_info", property = "fundInfo", typeHandler = com.crm.typehandler.JsonTypeHandler.class),
                    @Result(column = "exit_info", property = "exitInfo", typeHandler = com.crm.typehandler.JsonTypeHandler.class),
                    @Result(column = "justice_info", property = "justiceInfo", typeHandler = com.crm.typehandler.JsonTypeHandler.class),
                    @Result(column = "peer_info", property = "peerInfo", typeHandler = com.crm.typehandler.JsonTypeHandler.class),
                    @Result(column = "org_info", property = "orgInfo", typeHandler = com.crm.typehandler.JsonTypeHandler.class),
            })
//    @Select("select * from crm_partner where " +
//            "JSON_CONTAINS(over_area,JSON_OBJECT('province',#{overArea}))" +
//            " and JSON_CONTAINS(asset_info,JSON_OBJECT('type',#{type}))" +
//            " and JSON_CONTAINS(asset_info,JSON_OBJECT('belong',#{belong}))" +
//            " and JSON_CONTAINS(asset_info,JSON_OBJECT('bizType',#{bizType}))")
//    List<Partner> findAsset(String overArea,String type,String belong,String bizType);

    @Select({
            "<script>",
            "select * from crm_partner ",
            "where disabled=0 and partner_type=#{partnerType} ",
            "<if test='bizType != null and bizType!=\"\"'>",
            " and asset_info->'$.bizType'=#{bizType}",
            "</if>",
            "<foreach collection='cities' item='id' open='(' separator=' or ' close=')'>",
            " JSON_CONTAINS(over_area->'$[*][1]','\"${id}\"')",
            "</foreach>",
            "</script>",
    })
    List<Partner> findAsset(Integer partnerType, String bizType,
                            @Param("cities") String[] cities);


    @ResultMap(value = "partnerMap")
    @Select({
            "<script>",
            "select * from crm_partner ",
            "where disabled=0 and partner_type=#{partnerType} ",
            "<if test='post != null and bizType!=\"\"'>",
            " and post=#{post}",
            "</if>",
            "<foreach collection='cities' item='id' open='and (' separator=' or ' close=')'>",
            "  JSON_CONTAINS(over_area->'$[*][1]','\"${id}\"')",
            "</foreach>",
            "</script>",
    })
    List<Partner> findByPost(Integer partnerType, String post,
                             @Param("cities") String[] cities);


    /**
     * 根据类型查询所有信息
     *
     * @param partnerType
     * @return
     */
    @ResultMap(value = "partnerMap")
    @Select({
            "select * from crm_partner where disabled=0 and" +
                    " partner_type=#{partnerType} order BY update_time  DESC "
    })
    List<Partner> findByNameTel(Integer partnerType, String create_user_id);

    /**
     * 根据类型查询所有信息
     *
     * @param partnerType
     * @return
     */
    @ResultMap(value = "partnerMap")
    @Select({
            "<script>" +
                    "select crm_partner.* ,sys_user.true_name as trueName from crm_partner " +
                    "left join sys_user on crm_partner.create_user_id =sys_user.user_id where " +
                    " crm_partner.partner_type=#{partnerType}" +
                    "<if test='roleId != \"002\" '>" +
                    " and crm_partner.disabled=0" +
                    "</if>" +
                    " order BY crm_partner.update_time  DESC" +
                    "</script>"
    })
    List<Partner> findByNameTelHide(String roleId, Integer partnerType);

    @ResultMap(value = "partnerMap")
    @Select({"<script>" +
            "select * from crm_partner where disabled=0 " +
            "<if test='partnerType != null and partnerType!=\"\"'>" +
            " and partner_type = #{partnerType}",
            "</if>" +
                    "<if test='value != null and value!=\"\"'>" +
                    " and (telephone like '%${value}%' or  name like '%${value}%' or telephone_list->'$[*].telephones' like '%${value}%' or company like '%${value}%')",
            "</if>" +

                    " order BY update_time  DESC" +
                    "</script>"
    })
    List<Partner> findByBlurry01(Integer partnerType, String value);


    @ResultMap(value = "partnerMap")
    @Select({"<script>" +
            "select * from crm_partner where disabled=0 " +
            "<if test='createId !=null and createId!=\"\"'>" +
            " and create_user_id=#{createId}" +
            "</if>" +
            "<if test='partnerType != null and partnerType!=\"\"'>" +
            " and partner_type = #{partnerType}",
            "</if>" +
                    "<if test='value != null and value!=\"\"'>" +
                    " and (telephone like '%${value}%' or  name like '%${value}%' or telephone_list->'$[*].telephones' like '%${value}%' or" +
                    " company like '%${value}%')",
            "</if>" +
                    " order BY update_time  DESC" +
                    "</script>"})
    List<Partner> findByBlurry02(Integer partnerType, String value, String createId);


    /**
     * 根据 exit_info信息查询
     *
     * @param orgType   机构类型
     * @param orgRemark
     * @param usage     用途偏好
     * @param typeId    资产偏好
     * @param cities    区域
     * @return
     */
    @ResultMap(value = "partnerMap")
    @Select({
            "<script>",
            "select crm_partner.*,sys_user.true_name as trueName from crm_partner left join sys_user on crm_partner.create_user_id =sys_user.user_id " +
                    "where crm_partner.disabled=0 and crm_partner.partner_type = #{partnerType} " +
                    "<if test='usage != null and usage!=\"\"'>" +
                    "and  JSON_CONTAINS(exit_info->'$.usage[*]','\"${usage}\"')",
            "</if>" +
                    "<if test='typeId != null and typeId!=\"\"'>",
            " and json_contains(exit_info->'$.fancyList[*].typeId','\"${typeId}\"')",
            "</if>",
            "<if test='typeName != null and typeName!=\"\"'>",
            " and json_contains(exit_info->'$.fancyList[*].typeName','\"${typeName}\"')",
            "</if>",
            "<if test='createId != null and createId!=\"\"'>" +
                    " and crm_partner.create_user_id = #{createId}",
            "</if>" +
                    "<if test='orgType != null and orgType!=\"\"'>",
            " and  crm_partner.exit_type=#{orgType}",
            "</if>",
            "<if test='company != null and company!=\"\"'>" +
                    " and crm_partner.company like '%${company}%' ",
            "</if>" +
                    "<if test='orgRemark != null and orgRemark!=\"\"'>",
            " and crm_partner.org_remark = #{orgRemark}",
            "</if>",
            "<if test='abilityMin != null and abilityMin!=\"\"'>",
            " and cast(SUBSTRING(exit_info->'$.abilityMin',3,1 ) as UNSIGNED INTEGER) &gt;= #{abilityMin}",
            "</if>",
            "<if test='abilityMax !=null and abilityMax!=\"\"'>",
            " and cast(SUBSTRING(exit_info->'$.abilityMax',3,1 ) as UNSIGNED INTEGER) &lt;= #{abilityMax}",
            "</if>",
            "<if test='cities != null and cities.length>0'>" +
                    "<foreach collection='cities' item='id' open='and (' separator=' or ' close=')'>",
            "  JSON_CONTAINS(over_area->'$[*][1]','\"${id}\"')",
            "</foreach>" +
                    "</if>" +

                    " order BY crm_partner.update_time  DESC",
            "</script>",
    })
    List<Partner> findExitInfo(String createId, String company, Integer partnerType, String orgType, String orgRemark,
                               String usage,
                               String typeId, String typeName, @Param("cities") String[] cities, Integer abilityMin, Integer abilityMax);


    @ResultMap(value = "partnerMap")
    @Select({
            "<script>",
            "select crm_partner.*,sys_user.true_name as trueName from crm_partner left join sys_user on crm_partner.create_user_id =sys_user.user_id " +
                    "where crm_partner.partner_type = #{partnerType} " +
                    "<if test='depId != null and depId!=\"\"'>" +
                    " and sys_user.dep_id = #{depId}",
            "</if>" +
                    "<if test='createId != null and createId!=\"\"'>" +
                    " and crm_partner.create_user_id = #{createId}",
            "</if>" +
                    "<if test='usage != null and usage!=\"\"'>" +
                    "and  JSON_CONTAINS(exit_info->'$.usage[*]','\"${usage}\"')",
            "</if>" +
                    "<if test='typeId != null and typeId!=\"\"'>",
            " and json_contains(exit_info->'$.fancyList[*].typeId','\"${typeId}\"')",
            "</if>",
            "<if test='typeName != null and typeName!=\"\"'>",
            " and json_contains(exit_info->'$.fancyList[*].typeName','\"${typeName}\"')",
            "</if>",
            "<if test='orgType != null and orgType!=\"\"'>",
            " and  crm_partner.exit_type=#{orgType}",
            "</if>",
            "<if test='company != null and company!=\"\"'>" +
                    " and crm_partner.company like '%${company}%' ",
            "</if>" +
                    "<if test='orgRemark != null and orgRemark!=\"\"'>",
            " and crm_partner.org_remark = #{orgRemark}",
            "</if>",
            "<if test='abilityMin != null and abilityMin!=\"\"'>",
            " and cast(SUBSTRING(exit_info->'$.abilityMin',3,1 ) as UNSIGNED INTEGER) &gt;= #{abilityMin}",
            "</if>",
            "<if test='abilityMax !=null and abilityMax!=\"\"'>",
            " and cast(SUBSTRING(exit_info->'$.abilityMax',3,1 ) as UNSIGNED INTEGER) &lt;= #{abilityMax}",
            "</if>",
            "<if test='cities != null and cities.length>0'>" +
                    "<foreach collection='cities' item='id' open='and (' separator=' or ' close=')'>",
            "  JSON_CONTAINS(over_area->'$[*][1]','\"${id}\"')",
            "</foreach>" +
                    "</if>" +

                    " order BY crm_partner.update_time  DESC",
            "</script>",
    })
    List<Partner> findExitInfoSys(String depId, String createId, String company, Integer partnerType, String orgType, String orgRemark,
                                  String usage,
                                  String typeId, String typeName, @Param("cities") String[] cities, Integer abilityMin, Integer abilityMax);


    /**
     * 根据 peer_info信息查询
     *
     * @param orgType    机构类型
     * @param bizListId  业务类型
     * @param coopListId 合作方式
     * @param cities     区域
     * @return
     */
    @ResultMap(value = "partnerMap")
    @Select({
            "<script>",
            "select crm_partner.*,sys_user.true_name as trueName from crm_partner left join sys_user on crm_partner.create_user_id =sys_user.user_id" +
                    " where crm_partner.disabled=0  and crm_partner.partner_type = #{partnerType} " +
                    "<if test='bizListId != null and bizListId!=\"\"'>" +
                    " and json_contains(peer_info->'$.bizSList[*]','\"${bizListId}\"')" +
                    "</if>" +
                    "<if test='orgType != null and orgType!=\"\"'>" +
                    " and  JSON_CONTAINS(org_type->'$[*]' , '\"${orgType}\"')",
            "</if>" +
                    "<if test='createId != null and createId!=\"\"'>" +
                    " and crm_partner.create_user_id = #{createId}",
            "</if>" +

                    "<if test='coopListId != null and coopListId!=\"\"'>" +
                    " and json_contains(peer_info->'$.coopSList[*]','\"${coopListId}\"') " +
                    "</if>" +

                    "<if test='company != null and company!=\"\"'>" +
                    " and crm_partner.company like '%${company}%' ",
            "</if>" +
                    "<if test='cities != null and cities.length>0'>" +
                    "<foreach collection='cities' item='id' open='and (' separator=' or ' close=')'>",
            "  JSON_CONTAINS(over_area->'$[*][1]','\"${id}\"')",
            "</foreach>" +
                    "</if>" +
                    " order BY crm_partner.update_time  DESC",
            "</script>",
    })
    List<Partner> findPeerInfo(String createId, String company, Integer partnerType, String orgType,
                               String bizListId, String coopListId
            , @Param("cities") String[] cities);

    @ResultMap(value = "partnerMap")
    @Select({
            "<script>",
            "select crm_partner.*,sys_user.true_name as trueName from crm_partner left join sys_user on crm_partner.create_user_id =sys_user.user_id" +
                    " where crm_partner.partner_type = #{partnerType} " +
                    "<if test='depId != null and depId!=\"\"'>" +
                    " and sys_user.dep_id = #{depId}\n",
            "</if>" +
                    "<if test='createId != null and createId!=\"\"'>" +
                    " and create_user_id =#{createId} ",
            "</if>" +
                    "<if test='bizListId != null and bizListId!=\"\"'>" +
                    " and json_contains(peer_info->'$.bizSList[*]','\"${bizListId}\"')" +
                    "</if>" +
                    "<if test='orgType != null and orgType!=\"\"'>" +
                    " and  JSON_CONTAINS(org_type->'$[*]' , '\"${orgType}\"')",
            "</if>" +
                    "<if test='coopListId != null and coopListId!=\"\"'>" +
                    " and json_contains(peer_info->'$.coopSList[*]','\"${coopListId}\"') " +
                    "</if>" +

                    "<if test='company != null and company!=\"\"'>" +
                    " and crm_partner.company like '%${company}%' ",
            "</if>" +
                    "<if test='cities != null and cities.length>0'>" +
                    "<foreach collection='cities' item='id' open='and (' separator=' or ' close=')'>",
            "  JSON_CONTAINS(over_area->'$[*][1]','\"${id}\"')",
            "</foreach>" +
                    "</if>" +
                    " order BY crm_partner.update_time  DESC",
            "</script>",
    })
    List<Partner> findPeerInfoSys(String depId, String createId, String company, Integer partnerType, String orgType,
                                  String bizListId, String coopListId
            , @Param("cities") String[] cities);

    /**
     * 根据 justice_info 司法伙伴信息查询
     *
     * @return
     */
    @ResultMap(value = "partnerMap")
    @Select({"<script>",
            "select crm_partner.*,sys_user.true_name as trueName from crm_partner left join sys_user on crm_partner.create_user_id =sys_user.user_id" +
                    " where crm_partner.disabled=0 and crm_partner.partner_type = #{partnerType} ",
            "<if test='company != null and company!=\"\"'>",
            " and (JSON_EXTRACT(justice_info, '$.resumeList[*].resumeOrg') LIKE '%${company}%'" +
                    " or company like '%${company}%'" +
                    " or justice_info->'$.orgName' LIKE '%${company}%')",
            "</if>",
            "<if test='createId != null and createId!=\"\"'>" +
                    " and crm_partner.create_user_id = #{createId}",
            "</if>" +
                    "<if test='post != null and post!=\"\"'>",
            " and (JSON_EXTRACT(justice_info, '$.resumeList[*].resumePos') LIKE '%${post}%'" +
                    " or post like '%${post}%'" +
                    " or justice_info->'$.pos' LIKE '%${post}%')",
            "</if>",
            "<if test='cities != null and cities.length>0'>" +
                    "and (" +
                    "<foreach collection='cities' item='id' open='(' separator=' or ' close=')'>",
            "  JSON_CONTAINS(over_area->'$[*][2]','\"${id}\"') " +
                    "</foreach>",
            "<foreach collection='cities' item='id' open='or (' separator=' or ' close=')'>",
            " json_contains(justice_info ->'$.area[*][2]','\"${id}\"') " +
                    "</foreach>",
            "<foreach collection='cities' item='id' open='or (' separator=' or ' close=')'>",
            " json_contains(justice_info -> '$.resumeList[*].resumeOver[*][2]','\"${id}\"') " +
                    "</foreach>" +
                    ")",
            "</if>" +
                    " order BY crm_partner.update_time  DESC" +
                    "</script>"})
    List<Partner> findJusticeInfo(String createId, Integer partnerType, String company,
                                  String post, @Param("cities") String[] cities);

    @ResultMap(value = "partnerMap")
    @Select({"<script>",
            "select crm_partner.*,sys_user.true_name as trueName from crm_partner left join sys_user on crm_partner.create_user_id =sys_user.user_id" +
                    " where crm_partner.partner_type = #{partnerType} ",
            "<if test='depId != null and depId!=\"\"'>" +
                    " and sys_user.dep_id = #{depId}\n",
            "</if>" +
                    "<if test='createId != null and createId!=\"\"'>" +
                    " and crm_partner.create_user_id = #{createId}",
            "</if>" +
                    "<if test='company != null and company!=\"\"'>",
            " and (JSON_EXTRACT(justice_info, '$.resumeList[*].resumeOrg') LIKE '%${company}%'" +
                    " or company like '%${company}%'" +
                    " or justice_info->'$.orgName' LIKE '%${company}%')",
            "</if>",
            "<if test='post != null and post!=\"\"'>",
            " and (JSON_EXTRACT(justice_info, '$.resumeList[*].resumePos') LIKE '%${post}%'" +
                    " or post like '%${post}%'" +
                    " or justice_info->'$.pos' LIKE '%${post}%')",
            "</if>",
            "<if test='cities != null and cities.length>0'>" +
                    "and (" +
                    "<foreach collection='cities' item='id' open='(' separator=' or ' close=')'>",
            "  JSON_CONTAINS(over_area->'$[*][2]','\"${id}\"') " +
                    "</foreach>",
            "<foreach collection='cities' item='id' open='or (' separator=' or ' close=')'>",
            " json_contains(justice_info ->'$.area[*][2]','\"${id}\"') " +
                    "</foreach>",
            "<foreach collection='cities' item='id' open='or (' separator=' or ' close=')'>",
            " json_contains(justice_info -> '$.resumeList[*].resumeOver[*][2]','\"${id}\"') " +
                    "</foreach>" +
                    ")",
            "</if>" +
                    " order BY crm_partner.update_time  DESC" +
                    "</script>"})
    List<Partner> findJusticeInfoSys(String depId, String createId, Integer partnerType, String company,
                                     String post, @Param("cities") String[] cities);

    /**
     * 根据 org_info 政府伙伴信息查询
     */
    @ResultMap(value = "partnerMap")
    @Select({"<script>",
            "select crm_partner.*,sys_user.true_name as trueName from crm_partner left join sys_user on crm_partner.create_user_id =sys_user.user_id" +
                    " where crm_partner.disabled=0 and crm_partner.partner_type = #{partnerType} ",
            "<if test='company != null and company!=\"\"'>",
            " and (JSON_EXTRACT(org_info, '$.resumeList[*].resumeOrg') LIKE '%${company}%'" +
                    " or company like '%${company}%'" +
                    " or org_info->'$.name' LIKE '%${company}%')",
            "</if>",
            "<if test='post != null and post!=\"\"'>",
            " and (JSON_EXTRACT(org_info, '$.resumeList[*].resumePos') LIKE '%${post}%'" +
                    " or post like '%${post}%'" +
                    " or org_info->'$.pos' LIKE '%${post}%')",
            "</if>",
            "<if test='createId != null and createId!=\"\"'>" +
                    " and crm_partner.create_user_id = #{createId}",
            "</if>" +
                    "<if test='cities != null and cities.length>0'>" +
                    "and (" +
                    "<foreach collection='cities' item='id' open=' (' separator=' or ' close=')'>",
            "  JSON_CONTAINS(over_area->'$[*][2]','\"${id}\"') " +
                    "</foreach>",
            "<foreach collection='cities' item='id' open='or (' separator=' or ' close=')'>",
            " json_contains(org_info ->'$.relativeArea[*][2]','\"${id}\"') " +
                    "</foreach>",

            "<foreach collection='cities' item='id' open='or (' separator=' or ' close=')'>",
            " json_contains(org_info -> '$.resumeList[*].resumeOver[*][2]','\"${id}\"') " +
                    "</foreach>" +
                    ")",
            "</if>" +
                    " order BY crm_partner.update_time  DESC" +
                    "</script>"})
    List<Partner> findOrgInfo(String createId, Integer partnerType, String company,
                              String post, @Param("cities") String[] cities);

    @ResultMap(value = "partnerMap")
    @Select({"<script>",
            "select crm_partner.*,sys_user.true_name as trueName from crm_partner left join sys_user on crm_partner.create_user_id =sys_user.user_id" +
                    " where crm_partner.partner_type = #{partnerType} " +
                    "<if test='depId != null and depId!=\"\"'>" +
                    " and sys_user.dep_id = #{depId}\n",
            "</if>" +

                    "<if test='createId != null and createId!=\"\"'>" +
                    " and create_user_id =#{createId} ",
            "</if>" +
                    "<if test='company != null and company!=\"\"'>",
            " and (JSON_EXTRACT(org_info, '$.resumeList[*].resumeOrg') LIKE '%${company}%'" +
                    " or company like '%${company}%'" +
                    " or org_info->'$.name' LIKE '%${company}%')",
            "</if>",
            "<if test='post != null and post!=\"\"'>",
            " and (JSON_EXTRACT(org_info, '$.resumeList[*].resumePos') LIKE '%${post}%'" +
                    " or post like '%${post}%'" +
                    " or org_info->'$.pos' LIKE '%${post}%')",
            "</if>",
            "<if test='cities != null and cities.length>0'>" +
                    " and (" +
                    "<foreach collection='cities' item='id' open=' (' separator=' or ' close=')'>",
            "  JSON_CONTAINS(over_area->'$[*][2]','\"${id}\"') " +
                    "</foreach>",
            "<foreach collection='cities' item='id' open='or (' separator=' or ' close=')'>",
            " json_contains(org_info ->'$.relativeArea[*][2]','\"${id}\"') " +
                    "</foreach>",

            "<foreach collection='cities' item='id' open='or (' separator=' or ' close=')'>",
            " json_contains(org_info -> '$.resumeList[*].resumeOver[*][2]','\"${id}\"') " +
                    "</foreach>" +
                    ")",
            "</if>" +
                    " order BY crm_partner.update_time  DESC" +
                    "</script>"})
    List<Partner> findOrgInfoSys(String depId, String createId, Integer partnerType, String company,
                                 String post, @Param("cities") String[] cities);

    /**
     * 根据id查询
     *
     * @param partner_id
     * @return
     */
    @ResultMap(value = "partnerMap")
    @Select("select * from crm_partner where disabled=0 and partner_id=#{partner_id} " +
            "order BY update_time  DESC")
    List<Partner> findById(String partner_id);

    /**
     * 根据 telephone匹配telephone字段信息查询
     *
     * @param telephone
     * @param create_user_id
     * @return
     */
    @Select("select * from crm_partner where telephone=#{telephone} and" +
            " disabled =0 and create_user_id=#{create_user_id}  order by create_time DESC limit 0,1\n")
    @ResultMap(value = "partnerMap")
    Partner matchNumber(String telephone, String create_user_id);

    /**
     * 根据telephone匹配telephone_list字段查询信息
     *
     * @param telephone
     * @return
     */
    @Select("select * from crm_partner where\n" +
            " json_contains(telephone_list->'$[*].telephones','\"${telephone}\"') " +
            " and disabled =0 and create_user_id=#{create_user_id}  order by create_time DESC limit 0,1")
    @ResultMap(value = "partnerMap")
    Partner telephoneNumber(String telephone, String create_user_id);

    /**
     * 根据emain 匹配email字段信息
     *
     * @param email
     * @return
     */
    @Select("select * from crm_partner where email=#{email} " +
            "and disabled =0 and create_user_id=#{create_user_id}  order by create_time DESC limit 0,1")
    @ResultMap(value = "partnerMap")
    Partner emailNumber(String email, String create_user_id);

    @Select("select * from crm_partner where weixin=#{weixin} " +
            "and disabled =0 and create_user_id=#{create_user_id}  order by create_time DESC limit 0,1")
    @ResultMap(value = "partnerMap")
    Partner weixinNumber(String weixin, String create_user_id);


    @Select("SELECT COUNT(*) from crm_partner where disabled=0 " +
            "and create_user_id=#{createId}")
    Integer countCreateId(String createId);


    @Select("select sys_department.dep_name as depName,sys_user.true_name as trueName from sys_user  left join sys_department on sys_user.dep_id =sys_department.id\n" +
            "where sys_user.disabled=0 and sys_user.role_id='001' order BY sys_user.dep_id ")
    List<Workers> workers();

    @Select("select dep_name from sys_department")
    List<String> depName();

    @Select("select crm_partner.* ,sys_user.true_name as trueName from crm_partner left join sys_user on crm_partner.create_user_id =sys_user.user_id" +
            " where crm_partner.disabled=0 and  crm_partner.partner_type=#{partnerType} " +
            "and crm_partner.create_user_id=#{createUserId}")
    List<Partner> personal(int partnerType, String createUserId);


}
